home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 4 / Amiga Tools 4.iso / tools / packer / gnutar / source.lzh / source / sas_amiga.c < prev    next >
C/C++ Source or Header  |  1995-09-16  |  3KB  |  168 lines

  1.  
  2. /*
  3.  *  Amiga specific functions
  4.  */
  5.  
  6. #include <stdio.h>
  7. #include <stdlib.h>
  8. #include <string.h>
  9. #include <sys/dir.h>
  10. #include <sys/stat.h>
  11. #include <time.h>
  12.  
  13.  
  14. /* maxmium pathlength for AmigaDOS */
  15.  
  16. #define MAXPATHLEN (255) /* BSTR */
  17.  
  18.  
  19. /* definitions for our chmod() replacement, which should
  20.    the correct flags out of "(h)sparwed"
  21. */
  22.  
  23. #define H_BIT (7) /* Hidden  */
  24. #define S_BIT (6) /* Script  */
  25. #define P_BIT (5) /* Pure    */
  26. #define A_BIT (4) /* Archive */
  27. #define R_BIT (3) /* Read    */
  28. #define W_BIT (2) /* Write   */
  29. #define E_BIT (1) /* Execute */
  30. #define D_BIT (0) /* Delete  */
  31.  
  32.  
  33. /* Flags themselves */
  34.  
  35. #define H_VAL (1<<H_BIT) /* 128 = 2^7 */
  36. #define S_VAL (1<<S_BIT) /*  64 = 2^6 */
  37. #define P_VAL (1<<P_BIT) /*  32 = 2^5 */
  38. #define A_VAL (1<<A_BIT) /*  16 = 2^4 */
  39. #define R_VAL (1<<R_BIT) /*   8 = 2^3 */
  40. #define W_VAL (1<<W_BIT) /*   4 = 2^2 */
  41. #define E_VAL (1<<E_BIT) /*   2 = 2^1 */
  42. #define D_VAL (1<<D_BIT) /*   1 = 2^0 */
  43.  
  44.  
  45. /* Masks for High-Active, only specific bit not set (same as for low) */
  46.  
  47. #define H_SET (~(H_VAL))
  48. #define S_SET (~(S_VAL))
  49. #define P_SET (~(P_VAL))
  50. #define A_SET (~(A_VAL))
  51.  
  52.  
  53. /* Masks for Low-Active, only specific bit not set (same as for high) */
  54.  
  55. #define R_SET (~(R_VAL))
  56. #define W_SET (~(W_VAL))
  57. #define E_SET (~(E_VAL))
  58. #define D_SET (~(D_VAL))
  59.  
  60. int sas_chmod(char *filename, int modes)
  61. {
  62.  unsigned long mask = R_VAL | W_VAL | D_VAL | E_VAL; /* clear; low-active */
  63.  
  64.  
  65.  /* since the unix tar archives usually don't seem to have to correct
  66.     S_I flags set, we now do just override our own chmod()
  67.     replacement via always using standard "rwed" settings.
  68.     Until someone finds a better solution
  69.  */
  70.  
  71.  modes = S_IREAD | S_IWRITE | S_IEXECUTE | S_IDELETE;
  72.  
  73.  /* if(modes & S_IHIDDEN)   mask = mask|H_VAL; */
  74.     if(modes & S_ISCRIPT)   mask = mask|S_VAL;
  75.     if(modes & S_IPURE)     mask = mask|P_VAL;
  76.     if(modes & S_IARCHIVE)  mask = mask|A_VAL;
  77.     if(modes & S_IREAD)     mask = mask&R_SET;
  78.     if(modes & S_IWRITE)    mask = mask&W_SET;
  79.     if(modes & S_IEXECUTE)  mask = mask&E_SET;
  80.     if(modes & S_IDELETE)   mask = mask&D_SET;
  81.  
  82.  /* result = */ SetProtection(filename, mask);
  83.  
  84.  return(0); /* should have worked */
  85. }
  86.  
  87. char *getwd(char *buf)
  88. {
  89.     return(getcwd(buf, MAXPATHLEN));
  90. }
  91.  
  92. int readlink(char *path, char *name, int max)
  93. {
  94.     return(-1);
  95. }
  96.  
  97. int symlink(void)
  98. {
  99.     return(-1);
  100. }
  101.  
  102. int utime(void)
  103. {
  104.     return(0);
  105. }
  106.  
  107. int umask(void)
  108. {
  109.     return(0);
  110. }
  111.  
  112. int fork(void)
  113. {
  114.     return(-1);
  115. }
  116.  
  117. int execlp(void)
  118. {
  119.     return(-1);
  120. }
  121.  
  122.  
  123. int findgid(void)
  124. {
  125.     return(0);
  126. }
  127.  
  128. int finduid(void)
  129. {
  130.     return(0);
  131. }
  132.  
  133. int pipe(void)
  134. {
  135.     return(-1);
  136. }
  137.  
  138. int dup(void)
  139. {
  140.     return(-1);
  141. }
  142.  
  143. int setmode(void)
  144. {
  145.     return(0);
  146. }
  147.  
  148. extern int wildmat(char *s, char *p);
  149.  
  150. int fnmatch (char *pattern, char *string, int flags)
  151. {
  152.  wildmat(string, pattern);
  153. }
  154.  
  155. #include <sys/timeb.h>
  156.  
  157. void ftime(struct timeb *ftz)
  158. {
  159.  extern time_t timezone;
  160.  
  161.  (void)time(ftz->time);
  162.  
  163.  /* Set the timezone global. */
  164.  tzset();
  165.  
  166.  ftz->timezone = (int) timezone / 60;
  167. }
  168.